﻿@model MaguenBrokersMVC.Models.SeguroVehiculo
<script type="text/javascript">
    $(function () {
        $('#VehiculoTipoId').change(function () {
            var idTipoVehiculoSeleccionado = $(this).val();
            var idVehiculoMarcaSeleccionada = $('#VehiculoMarcaId').val();
            $.getJSON('@Url.Action("AjaxGetModelos", "SeguroVehiculo")', { idVehiculoTipo: idTipoVehiculoSeleccionado, idVehiculoMarca: idVehiculoMarcaSeleccionada },
            function (modelos) {
                var modelosSelect = $('#VehiculoModeloId');
                modelosSelect.empty();
                $.each(modelos, function (index, modelo) {
                    modelosSelect.append(
                        $('<option/>')
                            .attr('value', modelo.Value)
                            .text(modelo.Text)
                    );
                });
            });
        });
    });
    $(function () {
        $('#VehiculoMarcaId').change(function () {
            var idVehiculoMarcaSeleccionada = $(this).val();
            var idTipoVehiculoSeleccionado = $('#VehiculoTipoId').val();
            $.getJSON('@Url.Action("AjaxGetModelos", "SeguroVehiculo")', { idVehiculoTipo: idTipoVehiculoSeleccionado, idVehiculoMarca: idVehiculoMarcaSeleccionada },
            function (modelos) {
                var modelosSelect = $('#VehiculoModeloId');
                modelosSelect.empty();
                $.each(modelos, function (index, modelo) {
                    modelosSelect.append(
                        $('<option/>')
                            .attr('value', modelo.Value)
                            .text(modelo.Text)
                    );
                });
            });
        });
    });
</script>
@using (Html.BeginForm())
{
    @Html.ValidationSummary(true)
    <fieldset id="tablaPrincipal" style="width: 500px">
        <table>
            <tr>
                <td>@Html.LabelFor(model => model.Nombre)
                </td>
                <td>@Html.EditorFor(model => model.Nombre)
                    @Html.ValidationMessageFor(model => model.Nombre)
                </td>
            </tr>
            <tr>
                <td>@Html.LabelFor(model => model.Apellido)
                </td>
                <td>@Html.EditorFor(model => model.Apellido)
                    @Html.ValidationMessageFor(model => model.Apellido)
                </td>
            </tr>
            <tr>
                <td>@Html.LabelFor(model => model.Email)
                </td>
                <td>@Html.EditorFor(model => model.Email)
                    @Html.ValidationMessageFor(model => model.Email)
                </td>
            </tr>
            <tr>
                <td>@Html.LabelFor(model => model.Telefono)
                </td>
                <td>@Html.EditorFor(model => model.Telefono)
                    @Html.ValidationMessageFor(model => model.Telefono)
                </td>
            </tr>
            <tr>
                <td>@Html.LabelFor(model => model.VehiculoTipoId)
                </td>
                <td>@Html.DropDownList("VehiculoTipoId", String.Empty)
                    @Html.ValidationMessageFor(model => model.VehiculoTipoId)
                </td>
            </tr>
            <tr>
                <td>@Html.LabelFor(model => model.VehiculoMarcaId)
                </td>
                <td>
                    @Html.DropDownList("VehiculoMarcaId", String.Empty)
                    @Html.ValidationMessageFor(model => model.VehiculoMarcaId)
                </td>
            </tr>
            <tr>
                <td>@Html.LabelFor(model => model.VehiculoModeloId)
                </td>
                <td>@Html.DropDownList("VehiculoModeloId", String.Empty)
                    @Html.ValidationMessageFor(model => model.VehiculoModeloId)
                </td>
            </tr>
            <tr>
                <td>@Html.LabelFor(model => model.Combustible)
                </td>
                <td>@Html.EditorFor(model => model.Combustible)
                    @Html.ValidationMessageFor(model => model.Combustible)
                </td>
            </tr>
            <tr>
                <td>@Html.LabelFor(model => model.Año)
                </td>
                <td>@Html.EditorFor(model => model.Año)
                    @Html.ValidationMessageFor(model => model.Año)
                </td>
            </tr>
            <tr>
                <td>
                    <input type="submit" value="Cotizar" />
                </td>
                <td>
                    <h5 style="color: @ViewBag.Color">
                        @ViewBag.Message
                    </h5>
                </td>
            </tr>
        </table>
    </fieldset>
}
